yjx.directive('swiperTo', [function () {
    return {
        restrict: 'A',
        link: function ($scope, element, attr) {
            var touch = {
                _x: '',
                _y: ''
            };//x方向起始点
            var touched = {
                _x: '',
                _y: ''
            },//x方向终点
                moveX = 20;//X方向移动距离
            element.bind('touchstart', function (evt) {
                touch._x = evt.originalEvent.touches[0].clientX;
                touch._y = evt.originalEvent.touches[0].clientY;
            })
            element.bind('touchmove', function (evt) {
                touched._x = evt.originalEvent.touches[0].clientX;
                touched._y = evt.originalEvent.touches[0].clientY;
                if ((touch._x - touched._x) >= moveX) {
                    /**向左滑动显示删除按钮 */
                    element.context.scrollLeft = $scope.scrollLeft;
                    return
                }
                if((touched._x - touch._x) >= moveX){
                    /**向右滑动隐藏删除按钮 */
                    element.context.scrollLeft = 0;
                    return
                }
            })
            element.bind('touchEnd', function (evt) {
                touched._x = evt.originalEvent.touches[0].clientX;
                touched._y = evt.originalEvent.touches[0].clientY;
                if ((touch._x - touched._x) >= moveX) {
                    element.context.scrollLeft = $scope.scrollLeft;
                    return
                }
                if((touched._x - touch._x) >= moveX){
                    element.context.scrollLeft = 0;
                    return
                }
            })
           
        }
    }
}])